/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Bari
 */
@Entity
@Table(name = "activereservations")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Activereservation.findAll", query = "SELECT a FROM Activereservation a"),
    @NamedQuery(name = "Activereservation.findById", query = "SELECT a FROM Activereservation a WHERE a.id = :id"),
    @NamedQuery(name = "Activereservation.findByResourceid", query = "SELECT a FROM Activereservation a WHERE a.resourceid.id = :resourceid"),
    @NamedQuery(name = "Activereservation.findByEndtime", query = "SELECT a FROM Activereservation a WHERE a.endtime = :endtime"),
    @NamedQuery(name = "Activereservation.findByStarttime", query = "SELECT a FROM Activereservation a WHERE a.starttime = :starttime")})
public class Activereservation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "endtime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endtime;
    @Column(name = "starttime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date starttime;
    @JoinColumn(name = "userid", referencedColumnName = "id")
    @ManyToOne
    private User userid;
    @JoinColumn(name = "resourceid", referencedColumnName = "id")
    @ManyToOne
    private Resource resourceid;

    public Activereservation() {
    }

    public Activereservation(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getEndtime() {
        return endtime;
    }

    public void setEndtime(Date endtime) {
        this.endtime = endtime;
    }

    public Date getStarttime() {
        return starttime;
    }

    public void setStarttime(Date starttime) {
        this.starttime = starttime;
    }

    public User getUser() {
        return userid;
    }

    public void setUserid(User userid) {
        this.userid = userid;
    }

    public Resource getResource() {
        return resourceid;
    }

    public void setResourceid(Resource resourceid) {
        this.resourceid = resourceid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activereservation)) {
            return false;
        }
        Activereservation other = (Activereservation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Activereservation[ id=" + id + " ]";
    }
    
}
